package com.wzdigit.wms.wms.task;

import com.wzdigit.wms.wms.mapper.MaterialPeakMapper;
import com.wzdigit.wms.wms.service.report.MaterialPeakService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
    定时保存物料瞬间库存汇总数据
    * @author shuaic
    * @date 2021/9/23 21:26
*/
@ConditionalOnExpression("${schedule.common.switch}")
@Component
@Slf4j
public class MaterialPeakTask {

    @Autowired
    MaterialPeakService materialPeakService;

    @Scheduled(cron = "0 59 23 * * ?")
    public synchronized void saveData() {
        try {
            materialPeakService.saveMaterialPeak();
        }catch (Exception e){
            log.info("定时任务统计仓库物料峰值失败");
            e.printStackTrace();

        }

    }
}
